﻿<div class="lg-card" id="demo">
    <div class="lg-card-head">
        欢迎页
    </div>
    <div class="lg-card-body">
        <div class="lg-table">
            <div class="lg-table-tr">
                <div class="lg-table-td">
                    程序版本： {{bb}}
                </div>
                <div class="lg-table-td">
                    站点域名： www.langgine.com
                </div>
                <div class="lg-table-td">
                    语言版本： 中文版(CN)
                </div>
                <div class="lg-table-td">
                    文章总数： 8条 （总共） / 0条 （未发布）
                </div>
            </div>
        </div>
        <button v-on:click="GetHtml()">抓取测试</button>
    </div>
</div>
<div class="lg-card">
    <div class="lg-card-head">
        欢迎页
    </div>
    <div class="lg-card-body">
        <div v-html="cc">
        </div>
    </div>
</div>
<script>
    Vue.createApp({
        data() {
            return {
                bb: "1.0",
                cc: ""
            }
        },
        mounted: function() {
            new lg.page({
                mounted: function() {
                    var page = this;
                    console.log(page);
                }
            })
        },
        methods: {
            showPage: function() {
                Pages.RedirectTo({
                    url: "/Lgm/Test",
                    title: "测试页"
                })
            },
            change: function() {
                this.bb = "546721";
            },
            GetHtml: function() {
                $.ajax({
                    url: '/Base/GetHtml',
                    type: "Get",
                    data: {
                        url: "http://www.tsinglan.cn/index.php?m=content&c=index&a=lists&catid=2"
                    },
                    success: res => {
                        var json = lg.convert.toJson(res, false)
                        if (!json) {
                            var str = res.match(/<div class='news_list_box clear'>([\s\S]*)<!--<div class='info_bottom clear'>/)[0]
                            this.cc = str.replace(/<div class='news_list_box clear'>([\s\S]*)<!--<div class='info_bottom clear'>/, "$1")
                        }
                        else {
                            layer.msg(json.msg, { icon: 2 })
                        }
                    },
                    error: function(err) {
                        layer.msg(err.responseText)
                    }
                });
            }
        }
    }).mount("#demo")
</script>
